#ifndef _DSWWEBS_H
#define _DSWWEBS_H
#include <libbase/dswbase.h>

#ifdef __cplusplus
extern  "C" {
#endif

#ifndef WEBS
#define WEBS
#endif

#ifndef UEMF
#define UEMF
#endif

#ifndef OS
#define OS LINUX
#endif

#ifndef LINUX
#define LINUX
#endif

#include	<webs/uemf.h>
#include	<webs/wsIntrn.h>

#ifdef __cplusplus
}
#endif

class CDswwebs : public CDswbase
{
public:
	CDswwebs(LPST_ENV_T pEnv);
	virtual ~CDswwebs();
private:
	static void* cbWebThreadFunc(void* pParam){((CDswwebs*)pParam)->WebThreadFunc();return NULL;};
	void WebThreadFunc();

	void InitWebs();
	void UnInitWebs();

	static void BlockWrite(webs_t wp, char* pStr, int nLen);
	static int websHomePageHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg, char_t *url, char_t *path, char_t *query);

	void RegisterPages();
	static bool CheckValidKeyCode(char* pDevId, char* pKeyCode);
public:
	static int aspGetEthParam(int eid, webs_t wp, int argc, char_t **argv);
	static void formSetNetEth(webs_t wp, char_t *path, char_t *query);

	static int aspGetVideoParam(int eid, webs_t wp, int argc, char_t **argv);
	static void formSetVideoParam(webs_t wp, char_t *path, char_t *query);

	static int aspGetAudioParam(int eid, webs_t wp, int argc, char_t **argv);
	static void formSetAudioParam(webs_t wp, char_t *path, char_t *query);

	static int aspGetImageParam(int eid, webs_t wp, int argc, char_t **argv);
	static void formSetImageParam(webs_t wp, char_t *path, char_t *query);

	static int aspGetBasicDevInfo(int eid, webs_t wp, int argc, char_t **argv);
	static void formSetBasicDevInfo(webs_t wp, char_t *path, char_t *query);

	static int aspGetDiskInfo(int eid, webs_t wp, int argc, char_t **argv);
	static void formSetDiskFormat(webs_t wp, char_t *path, char_t *query);

	static int aspGetAlarmParam(int eid, webs_t wp, int argc, char_t **argv);
	static void formSetAlarmParam(webs_t wp, char_t *path, char_t *query);

	static int aspGetPlans(int eid, webs_t wp, int argc, char_t **argv);
	static void formSetPlans(webs_t wp, char_t *path, char_t *query);

	static int aspGetTime(int eid, webs_t wp, int argc, char_t **argv);
	static void formSetTime(webs_t wp, char_t *path, char_t *query);

	static int aspGetUser(int eid, webs_t wp, int argc, char_t **argv);
	static void formSetUser(webs_t wp, char_t *path, char_t *query);

	static void formSetReset(webs_t wp, char_t *path, char_t *query);

	static int aspGetInfo(int eid, webs_t wp, int argc, char_t **argv);
	static void formUpgrade(webs_t wp, char_t *path, char_t *query);

	static int aspGetLog(int eid, webs_t wp, int argc, char_t **argv);

	static void cbUpgrade(EN_UPGRADE_STEP nstep, double dpercent, void* pParam, void* pCaller);

	static int aspGetLDDevParam(int eid, webs_t wp, int argc, char_t **argv);
	static void formSetLDDevParam(webs_t wp, char_t *path, char_t *query);

	static int aspGetPTZADDRParam(int eid, webs_t wp, int argc, char_t **argv);
	static void formSetPTZADDRParam(webs_t wp, char_t *path, char_t *query);

	static int aspGetZoneParam(int eid, webs_t wp, int argc, char_t **argv);
	static void formSetZoneParam(webs_t wp, char_t *path, char_t *query);

	static int aspGetMenu(int eid, webs_t wp, int argc, char_t **argv);

	static int aspGetExtCam(int eid, webs_t wp, int argc, char_t **argv);
	static void formSetExtCam(webs_t wp, char_t *path, char_t *query);
private:
	pthread_t m_nWebThreadID;
};

#endif

